#include			"ImgManager.hpp"
#include			<iostream>

ImgManager*							ImgManager::_imgManag = 0;
std::map<std::string, sf::Image>	ImgManager::_mapImage;

ImgManager::ImgManager()
{}

ImgManager::~ImgManager()
{}

void				ImgManager::createImgManager()
{
	ImgManager::_imgManag = new ImgManager();

	sf::Image			Image;
	sf::Image			Image2;
	sf::Image			FondImg;
	sf::Image			Fire1;
    if (!Image.LoadFromFile("img/mob7_1.png") || !Image2.LoadFromFile("img/mob7_2.png") || !FondImg.LoadFromFile("img/fondEspace.png") || !Fire1.LoadFromFile("img/fireEnd.png"))
      exit(EXIT_FAILURE);

	Image.CreateMaskFromColor(sf::Color(255, 0, 255));
	Image2.CreateMaskFromColor(sf::Color(255, 0, 255));
	Fire1.CreateMaskFromColor(sf::Color(255, 0, 255));

	ImgManager::_mapImage["mob1"] = Image;
	ImgManager::_mapImage["mob2"] = Image2;
	ImgManager::_mapImage["back"] = FondImg;
	ImgManager::_mapImage["fireEnd"] = Fire1;
}

void				ImgManager::delImgManager()
{
	if (ImgManager::_imgManag != 0)
		delete ImgManager::_imgManag;
}

const sf::Image&	ImgManager::getImage(const std::string& name)
{
	if (ImgManager::isImage(name) == true)
		return (ImgManager::_mapImage.find(name)->second);
	else
		return (ImgManager::_mapImage.find("mob1")->second);
	
}

bool				ImgManager::isImage(const std::string& name)
{
	if (ImgManager::_mapImage.count(name) == 0)	
		return (false);
	return (true);
}
